Skip to content

Conversation

@njnu-seafish
Copy link
Contributor

Purpose of the pull request

close #17960

Brief change log

Add null/empty/duplicate validation logic for globalParams when creating or updating a workflow

Verify this pull request

This pull request is code cleanup without any test coverage.

(or)

This pull request is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(or)

Pull Request Notice

Pull Request Notice

If your pull request contains incompatible change, you should also add it to docs/docs/en/guide/upgrade/incompatible.md

@SbloodyS SbloodyS added the improvement make more easy to user or prompt friendly label Feb 6, 2026
@SbloodyS SbloodyS added this to the 3.4.1 milestone Feb 6, 2026
Comment on lines +296 to +302
try {
validateGlobalParams(globalParams);
} catch (ServiceException ex) {
log.warn("Invalid globalParams: {}", ex.getMessage());
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, ex.getMessage());
return result;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
try {
validateGlobalParams(globalParams);
} catch (ServiceException ex) {
log.warn("Invalid globalParams: {}", ex.getMessage());
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, ex.getMessage());
return result;
}
validateGlobalParams(globalParams);

Directly throw ServiceException at validateGlobalParams, please don't use a lot of try catch here.

Comment on lines +899 to +901
if (Direct.IN.equals(p.getDirect()) && StringUtils.isEmpty(p.getValue())) {
throw new ServiceException("IN param value required for key: " + key);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should support the value to be null.

/**
* Validates global parameters: non-empty keys, no duplicates, and required values for IN-type params.
*/
private void validateGlobalParams(String globalParams) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't be writing this kind of glue code everywhere. Why not use a GlobalParamValidator to handle this task?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend improvement make more easy to user or prompt friendly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Improvement][API] Add null/empty/duplicate validation logic for globalParams when creating or updating a workflow

3 participants